package com.kizuki.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Locale;

@Configuration
// @EnableWebMvc 意味全面接管springboot的配置
public class MyMVCConfig implements WebMvcConfigurer {


    // 定义一个自己的视图解析器
    @Bean
    public ViewResolver myViewResolver () {
        return new MyViewResolver();
    }


    static class MyViewResolver implements ViewResolver {
        @Override
        public View resolveViewName(String s, Locale locale) throws Exception {
            return null;
        }
    }


    // 或者override接口的方法
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/kizuki").setViewName("test");
    }

}
